package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TalarmDao;
import com.xy.manage.model.Talarm;
import com.xy.manage.service.TalarmService;

@Service
@Transactional
public class TalarmServiceImpl extends BaseServiceImpl<Talarm> implements
		TalarmService {
	private TalarmDao talarmDao;

	public TalarmServiceImpl(TalarmDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.talarmDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return talarmDao.checkExist("Talarm", paraName, paraValue);
	}

	@Override
	public List<Talarm> getTalarm(Map<String, Object> map) {
		return talarmDao.getTalarm(map);
	}
	@Override
	public Pagination getTalarmByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return talarmDao.getTalarmByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Talarm save(Talarm talarm) {
	//	talarm.setModtime(new Date());
		if(talarm.getAlarmid()==null){
			//新增
        	return super.save(talarm);
		}else{
			//更新
			Talarm talarm1=talarmDao.get(talarm.getAlarmid());
			try {
				BeanUtil.copyNotNullProperties(talarm1, talarm);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(talarm1);
		}
	}
}